package lab03.test01.test05;

import java.io.*;

/**
 * Created by Adminitrator on 2017/12/12.
 */
public class Test {
    public static void main(String[] args) {
        String path="D://java.txt";
        String path1="D://test(2).txt";
        BufferedWriter writer=null;
        BufferedWriter writer1=null;
        BufferedReader reader=null;
        try {writer=new BufferedWriter(new FileWriter(path));
            reader=new BufferedReader(new FileReader(path));
            writer1=new BufferedWriter(new FileWriter(path1));
            writer.write("Hello");
            String line;
            String str=null;
            while ((line=reader.readLine())!=null){
                for (int i=0;i<line.length();i++){
                    char ch=line.charAt(i);
                    if (Character.isLetter(ch)){
                        if (Character.isUpperCase(ch)){
                            if (ch-'A'+1>25){
                                ch=(char)(('A'+(ch-'A'+1)%26)+26);
                            }else {
                                ch=(char)(ch+1);
                            }
                        }
                    }
                    str=str+ch;
                }
                writer.write(str);
                writer1.newLine();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                writer.close();
                writer1.close();
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        System.out.println("文件加密完毕");

    }
}
